Skip to content

Bound v0.57 differential trace capture deterministically - #67

Merged
zhoubot merged 1 commit into
mainfrom
codex/release-0.57-trace-followup
Jul 17, 2026
Merged

Bound v0.57 differential trace capture deterministically#67
zhoubot merged 1 commit into
mainfrom
codex/release-0.57-trace-followup

Conversation

@zhoubot

@zhoubot zhoubot commented Jul 17, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • stop QEMU after a configurable trace prefix
  • clean up the QEMU child on normal and interrupted runs
  • avoid relying on a platform-specific timeout utility

Validation

  • clean merged QEMU versus pyCircuit fallback trace: 6 commits matched

The comparison flow now stops QEMU after a configurable trace prefix instead of relying on the guest finisher to terminate the process. Cleanup also owns the child process so interrupted runs cannot leak an emulator.

Constraint: The mcopy trace fixture intentionally enters a pass/fail terminal loop after its MMIO result.

Rejected: Add a platform-specific timeout dependency | macOS does not provide the GNU timeout command by default.

Confidence: high

Scope-risk: narrow

Directive: Keep the default prefix above the six-commit fallback comparison window.

Tested: clean merged QEMU versus pyCircuit fallback trace, six commits matched

Not-tested: Full non-fallback pyCircuit trace

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request updates the QEMU trace generation script to run QEMU in the background and poll its trace file until a minimum number of records is reached, rather than running it indefinitely. It also adds a cleanup function to terminate the QEMU process upon script exit. The feedback suggests increasing the polling sleep interval from 10ms to 100ms to prevent high CPU utilization caused by spawning processes in a tight loop, and safely capturing the line count to avoid potential syntax errors.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

Comment on lines +135 to +142
while kill -0 "${QEMU_PID}" >/dev/null 2>&1; do
if [[ -s "${QEMU_TRACE}" ]] &&
[[ "$(wc -l <"${QEMU_TRACE}")" -ge "${QEMU_TRACE_MIN_RECORDS}" ]]; then
kill -TERM "${QEMU_PID}" >/dev/null 2>&1 || true
break
fi
sleep 0.01
done

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Polling every 10ms (sleep 0.01) in a tight loop spawns two external processes (wc and sleep) up to 100 times per second. This process-spawning overhead can cause extremely high CPU utilization and significantly slow down execution, especially on macOS or virtualized environments. Additionally, fractional sleep values are not strictly POSIX-compliant and may fail on some minimal environments.

Consider increasing the sleep interval to 0.1 (100ms) or 0.05 (50ms) to drastically reduce CPU thrashing while remaining highly responsive. Also, capturing the output of wc -l in a variable with a default fallback (e.g., ${num_lines:-0}) prevents potential Bash syntax errors if the command substitution returns an empty string.

Suggested change
while kill -0 "${QEMU_PID}" >/dev/null 2>&1; do
if [[ -s "${QEMU_TRACE}" ]] &&
[[ "$(wc -l <"${QEMU_TRACE}")" -ge "${QEMU_TRACE_MIN_RECORDS}" ]]; then
kill -TERM "${QEMU_PID}" >/dev/null 2>&1 || true
break
fi
sleep 0.01
done
while kill -0 "${QEMU_PID}" >/dev/null 2>&1; do
if [[ -s "${QEMU_TRACE}" ]]; then
num_lines=$(wc -l <"${QEMU_TRACE}")
if [[ ${num_lines:-0} -ge "${QEMU_TRACE_MIN_RECORDS}" ]]; then
kill -TERM "${QEMU_PID}" >/dev/null 2>&1 || true
break
fi
fi
sleep 0.1
done

@zhoubot
zhoubot merged commit 88691b6 into main Jul 17, 2026
7 checks passed
@zhoubot
zhoubot deleted the codex/release-0.57-trace-followup branch July 17, 2026 09:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant